package Computer;

import javax.crypto.spec.PSource;

public class Compuer {
    public void poweron(){
        System.out.println("打开电脑");
    }
    public void poweroff(){
        System.out.println("关闭电脑");
    }


    public void use(IUSB usb){
        usb.open();
        if (usb instanceof Mouse){
            Mouse mouse = (Mouse) usb;
            ((Mouse) usb).click();
        }else {
            Keyboard keyboard = (Keyboard)usb;
            ((Keyboard) usb).imput();
        }
        usb.close();
    }

    public static void main(String[] args) {
        Compuer compuer = new Compuer();
        compuer.poweron();
        compuer.use(new Mouse());
        compuer.use(new Keyboard());
        compuer.poweroff();
    }
}
